#include <iostream>
using namespace std;

void bukva(int a)
{char i;
char bukv[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
i=bukv[a-10];
cout<<i;
}
void sys(int x, int system)
{
		int i=0,a[31]={0},c;
		for(;x>0;i++)
		{
		a[i]=x%system;
		x=x/system;
		}
		
		for(int j=i-1;j>=0;j--)
		{
			if(a[j]>=10)
			{
				c=a[j];bukva(c);
			}
		else cout<<a[j];}

		
}
int main()
{
       signed long int x, system;
		cout << "Input number: ";
        cin >> x;
        cout << "Input number system: ";
        cin >> system;
		sys(x,system);
		cout<<"\n";
	
}